package com.wzy.designpattern.creational.factory.Simple;

/**
 * 描述
 * 创建人    Wzy
 * 创建时间: 2020-05-15  13:05
 */
public class VideoFactory {


    public Video getVideo(String type) {
        if ("java".equalsIgnoreCase(type)) {
            return new JavaVideo();
        } else if ("python".equalsIgnoreCase(type)) {
            return new PythonVideo();
        }
        return null;
    }

    public Video getVideo2(Class<? extends Video> c) {
        Video video = null;
        try {
            video = (Video) Class.forName(c.getName()).newInstance();
        } catch (InstantiationException | ClassNotFoundException | IllegalAccessException e) {
            e.printStackTrace();
        }
        return video;
    }
}
